function $hash() {
    this.hashInit();
}

$hash.prototype.hashInit = function () {
    this.hashCode = (Math.random() + '').slice(2, 8);
}

$hash.prototype.hashHtml = function (str) {
    var hashTem = ` data-m-${this.hashCode} `;
    var template = str.replace(/<\w+\s*/gm, function (match) {
        return match + hashTem;
    });
    return template
}
$hash.prototype.hashCss = function (str) {
    var hashCss = `[data-m-${this.hashCode}]`;
    var cssTemplate = str.replace(/(:[^{]+[;}])|(\s*[{,])|(:{1,2}[^{]+\s*[{,])/gm, function (match, p1, p2, p3) {
        if (p1) {
            return p1;
        }
        if (p2) {
            return hashCss + p2;
        }
        if (p3) {
            return hashCss + match;
        }
    });
    return cssTemplate;
}
$hash.prototype.insertCss = function (str) {
    var e = document;
    var s = e.createElement('style');
    var t = e.createTextNode(this.hashCss(str));
    var h = e.head;
    s.appendChild(t).type = 'text/css';
    h.appendChild(s);
}